import { fetch } from '../utils/reuqest'
const api = {
    /**
    * mall
    */
   getIndexGoods: (data) => fetch('mall', 'mall/index', 'get', data), //首页
   getMenueList: (data) => fetch('mall', 'mallmenu/list', 'get', data), //首页分类列表
   getDetail: (id, data) => fetch('mall', `goods/${id}/detail`, 'get', data), //详情页
   addCollect: (data) => fetch('mall', 'goods/collection', 'post', data),  //商品收藏
   getCollecte: (data) => fetch('mall', 'goods/goodsIsCollected', 'get', data), //判断商品是否已收藏
   getGoodsList: (data) => fetch('mall', 'goods/list', 'get', data), //商品列表
   //加入购物车 type=1 ，立即购买 type=2
   addcart: (data) => fetch('mall', 'goods/addToCar', 'post', data),
   //我的购物车
   getCartList: (userId, data) => fetch('mall', `shoppingcart/list?userId=${userId}&type=0`, 'get', data),
   //更新购物车商品数量
   updateGoodsCount: (data) => fetch('mall', 'shoppingcart/update', 'post', data),
   //删除购物车商品
   deleteShoppingCartGoods: (cartId, userId, data) => fetch('mall', `shoppingcart/delete?shoppingCartIds=${cartId}&userId=${userId}`, 'DELETE', data),
   //确认订单查询商品信息
   getdata: (userId,shoppingCartIds, data) => fetch('mall', `shoppingcart/list?userId=${userId}&shoppingCartIds=${shoppingCartIds}&type=2`, 'get', data),
   /**
    * user
    */
   myFavorites: (userId,pagekey,data) => fetch('user', `user/${userId}/favorite?pagekey=${pagekey}`, 'get', data), //我的收藏
   delFavorite: (userId,goodsId,data)=> fetch('user',`user/delfavorite?userId=${userId}&userGoodsFavoriteId=${goodsId}`,'DELETE',data), //删除收藏商品
   /**
    * order
    */
   submitOrder:(data) => fetch('order','order/submit', 'post', data), //提交订单
   getOrderGoods :(userId,orderState,pageKey,data) => fetch('order', `order/${userId}/orderGoodsList?orderState=${orderState}&pageKey=${pageKey}`, 'get', data), //获取订单
   orderDetail:(orderId,userId,data)  => fetch('order', `order/${orderId}?userId=${userId}`, 'get', data), //订单详情
     
}
export default api